<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">

      <template v-slot:table-top>
        <el-alert :title="$tt('tip_returnGood_ownless_show')" type="warning" :closable="false" />
        <hr>
      </template>
    </ex_super_table_page>
    <ex_super_dialog_form ref="detailDialog" v-bind="detailDialog" @afterSubmitSuccess="reload()">

    </ex_super_dialog_form>


  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import emitOnFunction from '@/mixin/emit-on-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';

let emitKey = 'returngood>claim_log'
export default {
  title: 'label_return_order_ownless_claim_log',
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  components: {},
  data() {
    return {
      selection: [],
      option: {
        search: {
          default: {},
          model: [
            { key: 'returnOrderCode', label: 'label_return_order_code', },
            { key: 'trackingNumber', label: 'label_track_code', },
            { key: 'returnType', label: 'label_return_type', type: "select", enum: 'ReturnRetTypeEnum' },
            { key: 'unclaimedClaimType', label: 'label_claim_type', type: "select", enum: 'ReturnOrderUnclaimedClaimTypeEnum' },
            { key: 'reviewStatus', label: 'label_audit_status', type: "select", enum: 'OmsReturnUnclaimedReviewStatusEnum' },

          ],
        },
        table: {
          url: "/oms-api/refund/ReturnOrderRpc/select_claim.json",
          model: this.init_table_model(),
        },
      },

      detailDialog: {
        customClass: 'dialog_extra',
        detailUrl: "/oms-api/refund/ReturnOrderRpc/detail_claim.json",

        form: {
          default: {
          },
          model: [
            { header: "label_base_info", },
            {
              formType: "itemDesc",
              attrs: this.$defaultDescAttrs,
              model: [
                { key: 'trackingNumber', label: 'label_returnGood_track_code', },
                { key: 'warehouseName', label: 'label_returnGood_warehouse', formatter: (r, c, v, i) => this.$formatNameCode(v, r.warehouseCode), },
                { key: 'returnType', label: 'label_return_type', formatter: (r, c, v, i) => this.$enumShow(v, "ReturnOrderStatusEnum") },
                { key: 'unclaimedClaimType', label: 'label_claim_type', formatter: (r, c, v, i) => this.$enumShow(v, "ReturnOrderUnclaimedClaimTypeEnum") },
                { key: 'packageQuantity', label: 'label_package_count', },
                { key: 'itemsNumber', label: 'label_sku_count', },

                { key: 'claimUserName', label: 'label_claim_user', },
                { key: 'claimTiem', label: 'label_claim_time', formatter: (r, c, v, i) => this.$dateFormat(v) },
                {
                  key: 'reviewStatus', label: 'label_audit_status',
                  formatter: (r, c, v, i) => this.$enumShow(v, "OmsReturnUnclaimedReviewStatusEnum")
                },
                { key: 'reviewReason', label: 'label_audit_reason', },
                {
                  key: 'reviewUserName', label: 'label_audit_user',
                },
              ],
            },
            { header: "label_sku_specification", },
            {
              key: 'detailList', label: '', formType: "itemTable", height: "400",
              model: [
                { key: 'returnSkuCodeList', label: 'label_return_order_sku_code', 'min-width': 140, 'show-overflow-tooltip': true,formatter: (r, c, v) => v?v.join(','):'' },
                { key: 'isAbnormal', label: 'label_is_abnormal', 'width': 120, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum") },
                {
                  key: 'returnHandlingMethod', label: 'label_do_with_method', 'width': 140, 'show-overflow-tooltip': true,
                  formatter: (r, c, v, i) => this.$enumShow(v, "SkuReturnMethodEnum")
                },
                { key: 'skuOnlyCode', label: 'label_associated_sku', 'width': 140, 'show-overflow-tooltip': true, },
                { key: 'skuReturnQuantity', label: 'label_return_order_count', 'width': 130, 'show-overflow-tooltip': true, },
                {
                  key: 'photo', label: 'label_sku_photo', 'min-width': 140,
                  render: (h, { row }) => {
                    if (!row.attachedList) return
                    return (<div class="flex_row_wrap">
                      {row.attachedList.map(it => (<ex_image_view style="width: 7rem;height: 7rem;margin:0 5px" src={it.filePath} lazy fit="fill" preview-src-list={row.attachedList.map(p => p.filePath)} />))}
                    </div>)
                  }
                },
              ],
            },


          ],
          rules: {
          },
        }
      },

    };
  },
  methods: {
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true, keyGroup: 'label_table_operate' },
        {
          type: 'expandDesc', 'width': 100,
          expandDesc: {
            ...this.$defaultDescAttrs,
            model: [],
          },
        },
        { key: 'returnOrderCode', label: 'label_return_order_code', 'min-width': 140, 'show-overflow-tooltip': true, },

        { key: 'customerName', label: 'label_customer_name', 'width': 100, 'show-overflow-tooltip': true, },
        { key: 'customerCode', label: 'label_customer_code', 'width': 100, 'show-overflow-tooltip': true, },
        {
          key: 'trackingNumber', label: 'label_track_code', 'min-width': 140, 'show-overflow-tooltip': true,
        },
        {
          key: 'unclaimedClaimType', label: 'label_claim_type', 'width': 140, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "ReturnOrderUnclaimedClaimTypeEnum")
        },
        {
          key: 'returnType', label: 'label_return_type', 'width': 140, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "ReturnRetTypeEnum")
        },
        {
          key: 'reviewStatus', label: 'label_audit_status', 'width': 140, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "OmsReturnUnclaimedReviewStatusEnum")
        },
        {
          key: 'packageQuantity', label: 'label_package_count', 'width': 100, 'show-overflow-tooltip': true,
        },
        {
          key: 'itemsNumber', label: 'label_single_kind_count', 'width': 100, 'show-overflow-tooltip': true,
        },
        {
          key: 'warehouseName', label: 'label_returnGood_warehouse', 'width': 100, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$formatNameCode(v, r.warehouseCode)

        },
        { key: 'claimTiem', label: 'label_claim_time', 'width': 130, formatter: (r, c, v, i) => this.$dateFormat(v) },

        { key: 'gmtCreate', label: 'label_create_time', 'width': 130, formatter: (r, c, v, i) => this.$dateFormat(v) },

        {
          type: 'operate', width: 160, fixed: 'right', operate: [
            {
              label: 'label_view_detail', click: (row) => {
                this.$refs.detailDialog.showNew({
                  title: this.$tt("label_detail"),
                  params: {
                    id: row.id
                  },
                })
              }
            },

          ]
        }
      ]
    },

  }
};

</script>
